/*
Problem:    �շ�վ
Assemble:   NOIP_moni_10
Anthor:     Alchemist
Date:       2011.11.1
Tag:        Divide, Shortest Path
Difficulty: ****
Description:
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <list>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;
const int maxn = 10000 + 1;
int n, m, u, v, s;
int dv;

struct node
{
	int id,f;
}city[maxn] ;
vector<pair<int, int> > adj[maxn];
long long d[maxn];
bool ena[maxn];


void dijkstra(int start)
{
    priority_queue<pair<int, int> > q;

    memset(d,0x7f,sizeof(d));
    if(!ena[start])
        return;
    q.push(make_pair(0,start));
    d[start] = 0;
    while(!q.empty())
    {
        pair<int, int> p = q.top();
        int v = p.second;
        int e = -p.first;
        if(v == dv)
            break;
        if(d[v] > s)
            break;
        if(d[v] >= e)
        for(int i = 0; i < adj[v].size(); i ++)
        {
            int vd = adj[v][i].first;
            int ed = adj[v][i].second;
            if(e + ed < d[vd] && ena[vd])
            {
                d[vd] = e + ed;
                q.push(make_pair(-d[vd], vd));
            }
        }
        q.pop();
    }
}
/*
void spfa(int start)
{
    queue<int> q;

    memset(d,0x7f,sizeof(d));

    if(!ena[start])
        return;
    q.push(start);
    d[start] = 0;
    while(!q.empty())
    {
        int v = q.front();
        for(int i = 0; i < adj[v].size(); i ++)
        {
            int vd = adj[v][i].first;
            int ed = adj[v][i].second;
            if(d[v] + ed < d[vd] && ena[vd])
            {
                d[vd] = ed + d[v];
                q.push(vd);
            }
        }
        q.pop();
    }
}*/

int comp(const void* p, const void* q)
{
	return ((node*)p)->f - ((node*)q)->f;
}

int main()
{
    freopen("cost.in","r",stdin);
    freopen("cost.out","w",stdout);
    cin >> n >> m >> u >> v >> s;
    dv = v;
    for(int i = 0; i < n; i ++)
    {
        cin >> city[i].f;
		city[i].id=i + 1;
		ena[i] = 1;
    }
	ena[n] = 1;

    for(int i = 0; i < m ; i ++)
    {
        int a,b,w;
        cin >> a >> b >> w;
        adj[a].push_back(make_pair(b,w));
        adj[b].push_back(make_pair(a,w));
    }

	qsort(city,n,sizeof(node),comp);
	/*
    for(int i = 0; i < n ; i ++)
	{
		cout << city[i].f << ' ' << city[i].id << endl;
	}*/
	int left,right,mid,ym;
	left = 0;
	right = n - 1;
	mid = n - 1;
	while(left < right)
	{
		ym = mid;
		mid = (left + right) / 2;
		if(mid == ym)
			break;
		if(ym < mid)
			for(int i = ym; i <= mid; i ++)
				ena[city[i].id] = true;
		else
			for(int i = mid + 1; i <= ym; i ++)
				ena[city[i].id] = false;
		dijkstra(u);
		if(d[v] <= s)
			right = mid;
		else
			left = mid;
	}
	while(mid < n)
	{
		dijkstra(u);
		if(d[v] <= s)
		{
			cout << city[mid].f << endl;
			return 0;
		}
		ena[city[++mid].id] = true;
	}
	cout << -1 << endl;
    return 0;
}
